package com.agileboot.domain.system.tag.query;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.agileboot.domain.system.tag.db.SysTagEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 标签分页查询
 * 仿照 NoticeQuery
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class TagQuery extends AbstractPageQuery<SysTagEntity> {

    private String tagType;

    private String tagName;

    private String creatorName;

    @Override
    public QueryWrapper<SysTagEntity> addQueryCondition() {
        QueryWrapper<SysTagEntity> queryWrapper = new QueryWrapper<SysTagEntity>()
                .like(StrUtil.isNotEmpty(tagName), "tag_name", tagName)
                .eq(StrUtil.isNotEmpty(tagType), "tag_type", tagType)
                .eq("t.deleted", 0)
                .like(StrUtil.isNotEmpty(creatorName), "u.username", creatorName);
        return queryWrapper;
    }
}
